<?php
namespace Assist\Controller;

class CarboxController extends AssistController {
    public function index(){
        $category = $this->catalog();
        /* 获取当前分类列表 */
        $Document = D('Document');
        $list = $Document->page($p, $category['list_row'])->lists($category['id'],'`level` DESC,`id` DESC');
        if(false === $list){
            $this->error('获取列表数据失败！');
        }
        
        $doclist = array();
        foreach($list as $item){
            $doclist[] = $Document->detail($item['id']);
        }
        
        /* 模板赋值并渲染模板 */
        $this->assign('category', $category);
        $this->assign('id',$id);
        $this->assign('list', $doclist);
        $this->assign('info',$info);
        $this->display();
    }
    
    protected function catalog(){
        $category = D('Category')->info('carbox');
        if($category && 1 == $category['status']){
            switch ($category['display']) {
                case 0:
                    $this->error('该分类禁止显示！');
                    break;
                //TODO: 更多分类显示状态判断
                default:
                    return $category;
            }
        } else {
            $this->error('分类不存在或被禁用！');
        }
    }
}